package com.tina.controller;

import com.tina.util.MailUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.util.Date;

/**
 * @Author tina
 * @Time 2020/12/3 下午3:24
 * @Version 1.0
 * @Content 发送邮箱
 **/
@Slf4j
@RestController
public class MailController {

    @Autowired
    private MailUtil mailUtil;

    @GetMapping("sendMail")
    public void sendMail() {
        Context context = new Context();
        context.setVariable("productName", "茉莉花白色");
        context.setVariable("productPrice", "89￥");
        context.setVariable("productImg", "https://s3.ax1x.com/2020/12/03/D7HE5V.jpg");
        mailUtil.sendMail("pigsroot@gmail.com", "下单成功", "mail", context);
    }
}
